package com.mzj.saas.mservice.eligible.repository;

import com.mzj.saas.mservice.eligible.entity.WaitingRentRecord;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

import java.util.List;

public interface WaitingRentRecordRepository extends PagingAndSortingRepository<WaitingRentRecord, Long>, JpaSpecificationExecutor<WaitingRentRecord> {
    List<WaitingRentRecord> findByOrgIdAndResidenceCommunityIdAndStatus(Long orgId, String residenceCommunityId, Integer status);

    @Modifying
    @Query(value = "UPDATE `saas_waiting_rent_record` r SET r.status=1 WHERE r.`id` = ?", nativeQuery = true)
    int updateStatusById(Long id);

    WaitingRentRecord findByApplyId(Long applyId);

    WaitingRentRecord findByApplyIdAndMatchUserIdAndOrgIdAndResidenceCommunityId(Long applyId,String matchUserId, Long orgId, String residenceCommunityId);

    List<WaitingRentRecord> findByApplyIdAndMatchUserId(Long applyId,String matchUserId);

}
